package com.ms.game.slot.base;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ms.game.slot.base.message.CSlotCommonDmSetRecvSeatUpdatePageRequest;
import com.ms.game.slot.base.message.SDMDoSeatRequest;
import com.ms.game.slot.base.message.SDMSeatStatChangeRequest;
import com.ms.game.slot.base.message.SlotBasicDMMessageRequest;
import com.ms.service.module.processer.BasiceServiceProcesser;
import com.xpec.c4.game.datamanager.BaseDataInfo;
import com.xpec.c4.game.utility.GameUtility;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.annotations.MessageType;
import com.xpec.c4.service.common.BaseMessageAction;

/**
 * slot dm 基本訊息
 * @author TW15012
 *
 */
public class SlotDMBasicAction extends BaseMessageAction
{
	private static final Log log = LogFactory.getLog(SlotDMBasicAction.class);
	
	@MessageType(typeCode = MessageTypes.C_SLOT_DM_DOSEAT)
	public void revDoSeat(SlotBasicDMMessageRequest request)
	{
		this.getModule().getBasicprocesser().revDMDoSeat((SDMDoSeatRequest)request);
	}
	
	
	@MessageType(typeCode = MessageTypes.S_SLOT_DM_SEATSTAT_CHANGE)
	public void revLeaveSeat(SlotBasicDMMessageRequest request)
	{
		this.getModule().getBasicprocesser().revDMSeatStatchange((SDMSeatStatChangeRequest)request);
	}
	
	
	@MessageType(typeCode = MessageTypes.S_SLOT_VERIFYEXPRIED)
	public void revVerifyExpried(SlotBasicDMMessageRequest request)
	{
		this.getModule().getBasicprocesser().revVerifyExpried(request);
	}
	
	/**
	 * client 指定要收哪一頁的座位更新資訊<br>
	 * 消息號碼:
	 * {@link MessageTypes#C_SLOT_COMMON_DM_SET_RECV_SEAT_UPDATE_PAGE_REQUEST}
	 * 
	 * @param request
	 */
	@MessageType(typeCode = MessageTypes.C_SLOT_COMMON_DM_SET_RECV_SEAT_UPDATE_PAGE_REQUEST)
	public void revSetRecvSeatUpdatePageRequest(CSlotCommonDmSetRecvSeatUpdatePageRequest request) {
		BasiceServiceProcesser<?> proc = this.getModule().getBasicprocesser();

		if (proc instanceof IDoorManSeatUpdateBroadcaster) {
			IDoorManSeatUpdateBroadcaster dmProc = (IDoorManSeatUpdateBroadcaster) proc;
			dmProc.revSetRecvSeatUpdatePageRequest(request);
		}
	}

	public void onPlayerDataAgentBack(BaseDataInfo obj, Object... userObject) {
		try
		{
			this.getModule().getBasicprocesser().onPlayerDataAgentBack(obj, userObject);
		}
		catch 
		(
				NoSuchMethodException | SecurityException
				| IllegalAccessException | IllegalArgumentException
				| InvocationTargetException | ClassNotFoundException e) 
		{
			if(log.isErrorEnabled()){
				log.error(GameUtility.getCurMethodName(), e);
			}
		}
	}
}
